#include <XBee.h>
#include <SoftwareSerial.h>

XBee xbee = XBee();

long Saddress;

SoftwareSerial NewSerial(2,3);

byte payload[] = {0 , 0};
uint8_t option = 0;
uint8_t data = 0;

XBeeResponse response = XBeeResponse();
Rx16Response rx16 = Rx16Response();
Rx64Response rx64 = Rx64Response();


Tx16Request tx = Tx16Request(Saddress, payload, sizeof(payload));
TxStatusResponse txStatus = TxStatusResponse();


void setup(){
  Serial.begin(9600);
  Serial.println("Serial Communications opened");
  xbee.begin(9600);
  
}

void loop(){
  xbee.readPacket();
  Serial.println("Reading for Packets");
  
  if (xbee.getResponse().isAvailable()) { //if something got
    if (xbee.getResponse().getApiId() == RX_16_RESPONSE) {
      xbee.getResponse().getRx16Response(rx16);
      option = rx16.getOption();
      data = rx16.getData(0);
      Saddress = rx16.getRemoteAddress16();
      Serial.println(Saddress);
    }
    else{
      xbee.getResponse().getRx64Response(rx64);
      option = rx64.getOption();
      data = rx64.getData(0);
      //Saddress = rx64.getRemoteAddress64();
      Serial.println("recieved a 64 bit address");
    }
  }
}
  
  
  
